#include "BSTree.h"


namespace czb 
{
	void func1()
	{
		BSTree<int> Tree;
		Tree.Insert(100);
		Tree.Insert(3);
		Tree.Insert(10);
		Tree.Insert(19);
		Tree.Insert(5);
		Tree.MideOrder();

		cout<<endl<<"1:"<<Tree.FindR(1) << endl;
		cout<<"100:"<< Tree.FindR(100) << endl;
		cout<<"19:"<<Tree.FindR(19) << endl;
	}

	void func2()
	{
		BSTree<int> Tree;
		Tree.Insert(100);
		Tree.Insert(3);
		Tree.Insert(10);
		Tree.Insert(19);
		Tree.Insert(5);
		Tree.MideOrder();
		cout << endl;
		
		Tree.Erase(10);
		Tree.MideOrder();

		cout << endl;
		BSTree<int> T(Tree);
		T.MideOrder();
	}

	void func3()
	{
		BSTree<int> Tree;
		Tree.InsertR(100);
		Tree.InsertR(3);
		Tree.InsertR(10);
		Tree.InsertR(19);
		Tree.InsertR(5);
		Tree.MideOrder();

		cout << endl << "1:" << Tree.FindR(1) << endl;
		cout << "100:" << Tree.FindR(100) << endl;
		cout << "19:" << Tree.FindR(19) << endl;
	}

	void func4()
	{
		BSTree<int> Tree;
		Tree.Insert(100);
		Tree.Insert(3);
		Tree.Insert(10);
		Tree.Insert(19);
		Tree.Insert(5);
		Tree.MideOrder();
		cout << endl;

		Tree.EraseR(10);
		Tree.MideOrder();

	}

	void func5()
	{
		key_value<int,string> kv;
		kv.Insert(3, "abc");
		kv.Insert(21, "efd");
		kv.Insert(10, "777dg");
		kv.Insert(44, "7dghd");
		kv.MideOrder();
		cout << endl;
		kv.Erase(21);

		kv.MideOrder();
		cout << endl;
		auto node = kv.Find(44);
		cout << node->_key<<" " << node->_value << endl;
	}
}


int main()
{
	czb::func5();
}